#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <poll.h>


int main(int argc, char **argv)
{
	int fd;
	int keyval;
	int ret;
	struct pollfd fds[1];
	
	fd = open("/dev/forth_drv", O_RDWR);
	if(fd < 0)
	{
		printf("Can't open forth_drv\n\r");
		return -1;
	}

	fds[0].fd = fd;
	fds[0].events = POLLIN;
	while(1)
	{
		ret = poll(fds, 1, 5000);
		if(ret == 0)
		{
			printf("time out!\n\r");
		}
		else
		{
			read(fd, &keyval, 1);
			printf("keyval = 0x%x\n\r", keyval);
		}
	}
	return 0;
}

